#ifndef __EPOLL_H__
#define __EPOLL_H__

#include <sys/epoll.h>
#include <fcntl.h>
#include <unistd.h> //close
#include <cassert>
#include<iostream>
#include <vector>
#include "Log.h"

class Epoll
{
    static const int max_event=1024;
public:
    Epoll(int events=max_event);
    ~Epoll();
    bool AddFd(int fd, uint32_t event);
    bool DelFd(int fd, uint32_t event);
    bool ModFd(int fd, uint32_t event);
    int Wait(int timeoutMs = -1);

    int GetEventFd(size_t i) const;

    uint32_t GetEvents(size_t i) const;

private:
    int epfd_;
    std::vector<struct epoll_event> events_;
};

#endif